package com.tencreat.domain.mall.dto;

import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;

/**
 * 砍价入参
 * @author zixin
 * @since 2021-12-22
 */
@Data
public class MallGoodsCutBargainDTO {

    @ApiModelProperty(value = "用户unionId", required = true)
    @NotBlank
    private String unionId;

    @ApiModelProperty(value = "用户头像")
    private String avatar;

    @ApiModelProperty("用户名称")
    private String nickname;

    @ApiModelProperty("订单号")
    private String orderSn;

    /** 如果获取不到名称则给一个默认的*/
    public void initialize() {
        if (StrUtil.isEmpty(this.nickname)) {
            this.nickname = RandomUtil.randomString(8);
        }
    }
}
